const mongoose = require("mongoose"); // 引入mongoose
// const colors = require("colors/safe");

/* 连接到数据库  mongoose.connect('mongodb://端口号/数据库'); */
// mongoose.connect("mongodb://localhost/Test");

// 如果有用户名与密码的连接方式 mongoose.connect('mongodb://用户名:密码@地址:端口号/数据库');
const host = process.env.host;
const database = process.env.database;
const username = process.env.username;
const password = process.env.password;
mongoose.connect(
  `mongodb://${username}:${password}@${host}/${database}`,
  {
    authSource: "admin",
  }
)

module.exports = mongoose;
